import React from 'react'

import {connect }from 'react-redux'
import {addGUN,removeGUN,addGunAsync} from './index.redux.js'

const mapStatetoProps = (state)=>{
    return {num: state.counter}
}

const actionCreators = {
    addGUN,removeGUN,addGunAsync
}

@connect(mapStatetoProps,actionCreators)
class App extends React.Component {

    // constructor(props){
    //     super(props)
    // }

    render(){

        return (
            <div>

        <h1>现在有机枪{this.props.num}把</h1>
        <button onClick={this.props.addGUN
        }>申请加机关枪
        </button>
        <button onClick={this.props.removeGUN
        }>-加机关枪
        </button>
        <button onClick={this.props.addGunAsync}>迟两天再给
        </button>

        </div>
        )
    }

}


App = connect(mapStatetoProps,actionCreators)(App)
export default App